<!-- BEGIN: PAGECONTENT -->
	<section class="grid_12">
	    <div class="block-border">
	        <form class="block-content form" id="sort_form" method="post" action="submit.php?ctrl={CONTROLLER}&act={ACTION}">
	            <h1>{SORTTITLE}</h1>                    
	            <div class="block-controls">
	                <ul class="controls-buttons">
	                    <li><a href="javascript:window.location.reload( false )"><img src="content/site/images/icons/fugue/arrow-circle.png" width="16" height="16"></a></li>
	                </ul>                        
	            </div>
	            <div class="no-margin">
	                <div class="vertical-scorll" id="vertical-scorll">
	                    <ol class="sortable" id="easymm">
							<!-- BEGIN: ITEM -->
							<li id="list_{ITEM.ID}">
								<div>
									<img src="{ITEM.ImageLink}" title="{ITEM.ImageTitle}" alt="{ITEM.ImageAlt}"/>
								</div>
							</li>
							<!-- END: ITEM -->
						</ol>
	                </div>
	            </div>
	                    
	            <div class="block-footer no-margin">
	                <img src="content/site/images/icons/fugue/arrow-curve-000-left.png" width="16" height="16" class="picto">
	                <input type="submit" name="submit" value="Cập nhật" class="button">
	                <a href="maincontent.php?ctrl={CONTROLLER}&act=view-grid&fid={TYPE}"><input type="button" name="submit" value="Hủy bỏ" class="button"></a>
					<span class="message_content"> Tổng số: {TOTALCOUNT}| {TOTALPAGE} page</span>
	            </div>
	        </form>
	    </div>
	</section>
	<script>
	     $(document).ready(function($) {
	    	 
	    	 $('ol.sortable').nestedSortable({
	             disableNesting: 'no-nest',
	             forcePlaceholderSize: true,
	             handle: 'div',
	             helper: 'clone',
	             items: 'li',
	             maxLevels: 1,
	             opacity: .6,
	             placeholder: 'placeholder',
	             revert: 250,
	             tabSize: 25,
	             tolerance: 'pointer',
	             toleranceElement: '> div'
	         });
	        
	        /* update menu / save menu position
	        ------------------------------------------------------------------------- */
	        //var orderNew = JSON.stringify($('ol.sortable').nestedSortable('toArray', {startDepthCount: 0}));
	        $("#sort_form").submit(function(){
	             if (confirm("Cập nhật vị trí của danh mục?")){
	                 $.ajax({
	                     type : "POST",
	                     url : $('#sort_form').attr('action'),
	                     data: $("ol.sortable").nestedSortable("serialize"),
	                     dataType : "json",
	                     success : function(msg) {
	                         alert(msg.message);
	                         if( msg.status =="ok" ){
	                        	 window.location.href = "maincontent.php?ctrl={CONTROLLER}&act=view-grid&fid={TYPE}";
	                         }
	                     },
	                     error : function(xhr, ajaxOptions, thrownError) {
	                         alert("Pegasus: có lỗi trong quá trình gửi dữ liệu!");
	                     }
	                 });
	             }
	             return false;
	         });
	    	
	    });
	</script>
<!-- END: PAGECONTENT -->